<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>生产者</title>
		<script src="../js/mui.min.js"></script>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/style.css" />
		<link rel="stylesheet" href="../css/iconfont.css" />
		<link rel="stylesheet" href="../css/css.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" id='tou'>生产者</h1>
			<h1 class="mui-title list_search" id='search' style="display: none;">
				<input type="text" id='search_name' placeholder="输入商家">
				<button type="button" onclick="sou()">搜索</button>
			</h1>
			<!--<a class="mui-icon iconfont icon-sousuo-sousuo mui-pull-right search"></a>-->
			<a class="mui-icon mui-icon-search mui-pull-right search"></a>
		</header>

		<div class="mui-content">
			<div class="index_nav shoplis_nav">
				<ul class="mui-table-view mui-grid-view mui-grid-9">
					<li class="mui-table-view-cell" onclick="tiao(1)">
						<a href="javascript:;">
							<span class="mui-icon iconfont icon-hezuo"></span>
							<div class="mui-media-body">合作社</div>
						</a>
					</li>
					<li class="mui-table-view-cell" onclick="tiao(2)">
						<a href="javascript:;">
							<span class="mui-icon iconfont icon-nongmaoshipin"></span>
							<div class="mui-media-body">家庭农场</div>
						</a>
					</li>
					<li class="mui-table-view-cell" onclick="tiao(4)">
						<a href="javascript:;">
							<span class="mui-icon iconfont icon-qiye"></span>
							<div class="mui-media-body">龙头企业</div>
						</a>
					</li>
				</ul>
			</div>
			<div class="shoplist_box">
				<ul class="shoplist" id="list">
					<!--<li>
						<a href="javascript:shopxq(78);" class="clearfix" style="width:100%;">
							<div class="shoplist_img"><img src="http://n1.073586.com/public/uploads/images/20170708/1499518667_965530.jpg"></div>
							<div class="shoplist_info">
								<div class="shoplist_spname clearfix">
									<span>犇犇牛场家庭农场</span>
									<span class="iconfont icon-dianhua"></span>
								</div>
								<div class="shoplist_spstyle">分类：龙头企业&nbsp;&nbsp;&nbsp;主营业务：草木花卉</div>
								<div class="index_spadr clearfix">
									<div class="shoplist_spadr_l"><span class="iconfont icon-location"></span>蓼江镇水口村</div>
									<div class="shoplist_spadr_r">17.3km</div>
								</div>
							</div>
						</a>
					</li>-->
				</ul>
			</div>
		</div>
		<div id="footer"></div>
		<div id="allmap"></div>
	</body>

</html>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/app.js" type="text/javascript"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=grTHl4v1H6uGFLChfz0aB0uQG4XWQv0k"></script>
<script type="text/javascript" src="../js/castapp.js"></script>
<script type="text/javascript" src="../js/layer/layer.min.js"></script>
<script type="text/javascript">
	getFoot(getUrlParam("foot_active") > 0 ? getUrlParam("foot_active") : 2);
	$(".search").click(function() {
		$("#top_title").toggle();
		$("#search").toggle();
	});

	function sou() {
		company = $("#search_name").val();
		$.ajax({
			type: "post",
			url: APP.api_url + "member/select",
			data: {
				company: company,
				k: k
			},
			dataType: 'jsonp',
			success: function(data) {
				var json = data.data;
				var listhtml = ""

				if(json.length != 0) {
					for(var i = 0; i < json.length; i++) {
						var pp = "";
						var mm = "";
						if(json[i].phone != '') {
							pp = '<span class="iconfont icon-dianhua" onclick="tel(' + json[i].phone + ')"></span>';
						}
						if(json[i].company_type == '1') {
							mm = '分类：合作社';
						}
						if(json[i].company_type == '2') {
							mm = '分类：家庭农场';
						}
						if(json[i].company_type == '3') {
							mm = '分类：农家乐';
						}
						if(json[i].company_type == '4') {
							mm = '分类：龙头企业';
						}
						listhtml += '<li><a href="javascript:shopxq(' + json[i].id + ');" class="clearfix" style="width:100%;"><div class="shoplist_img"><img src="' + APP.pic_url + json[i].pic + '"></div>' +
							'<div class="shoplist_info"><div class="shoplist_spname"><span>' + json[i].company +'</span>'+ pp + '</div>' +
							'<div class="shoplist_spstyle">' + mm + '&nbsp;&nbsp;&nbsp;&nbsp;主营业务：' + json[i].main_sell + '</div><div class="index_spadr clearfix">' +
							'<div class="shoplist_spadr_l"><span class="iconfont icon-location"></span>' + json[i].address + '</div>' +
							'<div class="shoplist_spadr_r">17.3km</div></div></div></a> </li>';
					}
				} else {
					listhtml = '<img src="../images/qq.png" />';
				}

				document.getElementById("list").innerHTML = listhtml;
			},

		});
	}
</script>

<script>
	$(function() {
		get_navigation();
		var loading = layer.load(0, {
			shade: false,
			time: 1 * 1000
		});
		k = getUrlParam('k') ? getUrlParam('k') : '';
		if(k != '') {
			var mm1 = "";
			if(k == '1') {
				mm1 = '合作社';
			}
			if(k == '2') {
				mm1 = '家庭农场';
			}
			if(k == '3') {
				mm1 = '农家乐';
				$('.index_list').hide();
			}
			if(k == '4') {
				mm1 = '龙头企业';
			}
			document.getElementById("tou").innerHTML = mm1;
			sou();
		} else {
			$.ajax({
				type: "post",
				url: APP.api_url + "member/shoplist",
				data: {},
				dataType: 'jsonp',
				success: function(data) {
					var json = data.data;
					var listhtml = "";
					if(json.length != 0) {
						for(var i = 0; i < json.length; i++) {
							var pp = "";
							var mm = "";
							if(json[i].phone != '') {
								pp = '<span class="iconfont icon-dianhua"  onclick="tel(' + json[i].phone + ')"></span>';
							}
							if(json[i].company_type == '1') {
								mm = '分类：合作社';
							}
							if(json[i].company_type == '2') {
								mm = '分类：家庭农场';
							}
							if(json[i].company_type == '3') {
								mm = '分类：农家乐	';
							}
							if(json[i].company_type == '4') {
								mm = '分类：龙头企业';
							}
							listhtml += '<li><a href="javascript:shopxq(' + json[i].id + ');" class="clearfix" style="width:80%;"><div class="shoplist_img"><img src="' + APP.pic_url + json[i].pic + '"></div>' +
								'<div class="shoplist_info"><div class="shoplist_spname">' + json[i].company + '</div>' +
								'<div class="shoplist_spstyle">' + mm + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;主营业务：' + json[i].main_sell + '</div><div class="index_spadr clearfix">' +
								'<div class="shoplist_spadr_l"><span class="iconfont icon-dingwei"></span>' + json[i].address + '</div>' +
								'<div class="shoplist_spadr_r">17.3km</div></div></div></a><div style="float:right;margin-top:-50px;"> ' + pp + '</div></li>';
						}
					} else {
						listhtml = '<img src="../images/qq.png" />';
					}
					document.getElementById("list").innerHTML = listhtml;
				},

			});

		}

	});

	function tel(p) {
		layer.msg(p);
	}

	function shopxq(id) {
		localStorage.setItem('shop_id', id); //存
		//var id=localStorage.getItem("shop_id");//取
		window.location.href = "shop.html";
	}

	function tiao(k) {
		window.location.href = "shoplist.html?k=" + k;
	}
</script>